package com.rainng.coursesystem.controller;

import com.rainng.coursesystem.config.themis.annotation.Admin;
import com.rainng.coursesystem.model.vo.request.BoolOptionVO;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.service.OptionService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/option")
@RestController
public class OptionController extends BaseController {
    private final OptionService service;

    public OptionController(OptionService service) {
        this.service = service;
    }

    @GetMapping("/allowMemberSelect")
    public ResultVO getAllowMemberSelect() {
        return service.getAllowMemberSelect();
    }

    @Admin(Admin.MEMBER_EVENT_MANAGE)
    @PutMapping("/allowMemberSelect")
    public ResultVO setAllowMemberSelect(@RequestBody @Validated BoolOptionVO option) {
        return service.setAllowMemberSelect(option.getOption());
    }

    @GetMapping("/allowLeaderBudget")
    public ResultVO getAllowLeaderBudget() {
        return service.getAllowLeaderBudget();
    }

    @Admin(Admin.MEMBER_EVENT_MANAGE)
    @PutMapping("/allowLeaderBudget")
    public ResultVO setAllowLeaderBudget(@RequestBody @Validated BoolOptionVO option) {
        return service.setAllowLeaderBudget(option.getOption());
    }
}
